package 输出和输入;

import java.io.*;

public class 序列化 {
    public static void main(String[] args) {
        Student stu=new Student();
        stu.setName("张三");
        stu.setXingbie("男");
        stu.setAge(19);
        FileOutputStream fos=null;
        ObjectOutput oos=null;
        try {
            fos=new FileOutputStream("F:/ddt.txt");
            oos=new ObjectOutputStream(fos);
            oos.writeObject(stu);
            oos.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (oos!=null){
                try {
                    oos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fos!=null){
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }



}
